class Solution(object):
    def maxSubArray(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """


        curNum =maxNum = nums[0]

        for i in range(1,len(nums)):
            curNum = max(curNum + nums[i],nums[i])
            maxNum = max(maxNum,curNum)
            i+=1
        return maxNum


        # cur = 0
        # acc = nums[0]
        #
        # for i in range(len(nums)):
        #     cur = max(nums[i],acc + nums[i])
        #     acc = max(cur,acc)
        # return acc


a = [-2,1]

s = Solution()
h= s.maxSubArray(a)
print(h)